let mysql = require('mysql');
let con = mysql.createConnection({
    host:'localhost',
    port:'3306',
    user:'root',
    password:'p081742linuxZH#',
    database:'new_schema'
});
con.connect();
let sql = 'SELECT * FROM  temp_table';
con.query(sql,function(err,result){
    if(err){
        console.log('[SELECT ERROE]-',err.message);
        return;
    }
    console.log(result);
});
/**   添加
 *var  addSql = 'INSERT INTO websites(Id,name,url,alexa,country) VALUES(0,?,?,?,?)';
 var  addSqlParams = ['菜鸟工具', 'https://c.runoob.com','23453', 'CN'];
 //增
 connection.query(addSql,addSqlParams,function (err, result) {
        if(err){
         console.log('[INSERT ERROR] - ',err.message);
         return;
        }

       console.log('--------------------------INSERT----------------------------');
       //console.log('INSERT ID:',result.insertId);
       console.log('INSERT ID:',result);
       console.log('-----------------------------------------------------------------\n\n');
});
 *   更新(修改)
 *
 * var modSql = 'UPDATE websites SET name = ?,url = ? WHERE Id = ?';
 var modSqlParams = ['菜鸟移动站', 'https://m.runoob.com',6];
 //改
 connection.query(modSql,modSqlParams,function (err, result) {
   if(err){
         console.log('[UPDATE ERROR] - ',err.message);
         return;
   }
  console.log('--------------------------UPDATE----------------------------');
  console.log('UPDATE affectedRows',result.affectedRows);
  console.log('-----------------------------------------------------------------\n\n');
});
 *    删除
 *
 *    var delSql = 'DELETE FROM websites where id=6';
 //删
 connection.query(delSql,function (err, result) {
        if(err){
          console.log('[DELETE ERROR] - ',err.message);
          return;
        }

       console.log('--------------------------DELETE----------------------------');
       console.log('DELETE affectedRows',result.affectedRows);
       console.log('-----------------------------------------------------------------\n\n');
});
 *
 *
 *
 *
 */




con.end();
